
import { POST } from "@/api";
import { config } from "@/config";
import { VagueOject, typee } from "@/types/common";
import { OrderType } from "@/types/res/order";
import { IndexType } from "@/types/res/home";
//登录
export const usermethod = async (data: VagueOject = {}, header: VagueOject = {}): Promise<string> => {

    return await POST<string>({
        url: config.apiList.userlogin,
        data,
        header
    })
}

//收藏
export const userlike = async (data: VagueOject = {}, header: VagueOject = {}): Promise<any> => {
    return await POST<any>({
        url: config.apiList.userlike,
        data,
        header
    })
}
//注册

export const useradd = async (data: VagueOject = {}, header: VagueOject = {}): Promise<any> => {
    return await POST<any>({
        url: config.apiList.useradd,
        data,
        header
    })

}

export const orderallOrder = async (data: VagueOject = {}, header: VagueOject = {}): Promise<typee[]> => {
    let res = await POST<typee[]>({
        url: config.apiList.orderallOrder,
        data,
        header
    })
    console.log("res", res)
    // @ts-ignore
    // res.forEach((v)=>{
    //     v.wares_masterimg=JSON.parse(<string>v.wares_masterimg)
    //     v.wares_infoimg= JSON.parse(<string>v.wares_infoimg)
    // })
    if (!res.length == 0) {
        res.forEach((v) => {
            v.wares_masterimg = JSON.parse(<string>v.wares_masterimg)
            v.wares_infoimg = JSON.parse(<string>v.wares_infoimg)
        })
        console.log(5555)
    } else {
        console.log(1111)
    }


    return res;






    // let res = await POST<IndexType[]>({
    //     url: config.apiList.index,
    //     data,
    //     header
    // })

    // res.forEach(v => {
    //     v.wares_masterimg = JSON.parse(<string>v.wares_masterimg)
    // })

}